#!/usr/bin/env python

from twisted.web import client
from twisted.internet import reactor

def printPage(data):
    print data
    reactor.stop()

def printError(failure):
    print >> sys.stderr, "Error: ", failure.getErrorMessage()
    reactor.stop()

def main(args):
    if len(args)==2:
        url=args[1]
        client.getPage(url).addCallback(printPage).addErrback(printError)
        reactor.run()
    else:
        print "Usage: webcat.py <URL>"

if __name__ == '__main__':
    import sys
    main(sys.argv)
